package openjdk.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;


public class TimeHandler implements InvocationHandler {

    private Object target;

    public TimeHandler(Object obj) {
        super();
        this.target = obj;
    }


    /**
     * @param proxy  proxied object
     * @param method proxied object's method
     * @param args   arguments of the proxied object.
     * @return
     * @throws Throwable
     */

    // proxy is the object which we proxy
    // method is the method of the proxy object
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(" Before moving ....");
        method.invoke(target);
        System.out.println(" After moving ....");

        return null;
    }
}